This function scans the folder specified by its FSSpec,
and stores the item information found in our global
dynamic array.
*/
Clear Local Fn CollectFileItems ( fSpec As .FSSpec )
'~'9
Dim As Short Index
Dim pb.128
#If Ndef _kFolderBit
_kFolderBit = 3
#Endif
Index = 1// start at index 1
Do
pb.ioFDirIndex% = Index// fill the param block
pb.ioNamePtr& = @fSpec.name// the folder requested
pb.ioVRefNum% = fSpec.vRefNum
pb.ioDirID& = fSpec.parID
If Fn PBGetCatInfoSync( pb ) Then Exit Do// get info on item and leave the loop on error
Long If ( pb.ioFlUsrWds.fdFlags% And _fInvisible ) = _false// skip invisible items
gFiles.itemID(Index) = Index// this index will become our DataBrowser itemID
gFiles.spec (Index) = fSpec// save the item FSSpec
Long If Fn BitTst (pb.ioFlAttrib%, _kFolderBit)// Is it a folder?
// it's a folder...
gFiles.type (Index) = _"fldr"// set the file type
gFiles.creator(Index) = _"----"// set the creator code
Xelse// it is a file...
gFiles.type (Index) = pb.ioFlUsrWds.fdType&// grab the info from the param block
gFiles.creator(Index) = pb.ioFlUsrWds.fdCreator&
gFiles.flags (Index) = pb.ioFlUsrWds.fdFlags%
gFiles.dataLen(Index) = pb.ioFlLgLen&
gFiles.rsrcLen(Index) = pb.ioFlRLgLen&
gFiles.cDate (Index) = pb.ioFlCrDat&
gFiles.mDate (Index) = pb.ioFlMdDat&
gFiles.attrib (Index) = pb.ioFlAttrib%
End If
End If
index++// next file or folder in the current folder
Until _nil
End Fn
'~-----
'~DataBrowser Setting & Getting Data
'~'1
/*
This function is called via a callback procedure. This is
the only required routine to work with a DataBrowser control.
The DataBrowser asks you to setup some values for the cells
that it must display. Those values are set with specific functions
depending on the type of the cell to be updated.
With the same callback routine the DataBrowser may inform your
program that a cell has been changed by the end user, so it is
time to get the value sent by the DataBrowser to update your
internal information.
*/
Clear Local Fn MyGetSetItemData( browser As ControlRef, itemID As DataBrowserItemID, columnPropID As DataBrowserPropertyID, itemData As DataBrowserItemDataRef, userChangedItemData As Boolean )
'~'9
Dim As OSStatus err
Dim As CFStringRef txt
Dim As IconRef iconH
Dim As FSSpec fSpec : fSpec = gFiles.spec(itemID)// copy info from the dynamic array...
Dim As OSType fType : fType = gFiles.type(itemID)// ... in local variables
err = _noErr
Long If userChangedItemData = _false
Select columnPropID// Which property has been requested by the DataBrowser
Case _fileColumnID' Names and icons for our unique column
Fn InstallDataBrowserCallbacks( browser )// Install the callback routines
Fn ConfigureDataBrowser( browser )// Configure the DataBrowser
err = Fn SetKeyboardFocus( wRef, browser, _kControlDataBrowserPart )// Set the keyboard focus
err = Fn SetWindowProperty( wRef, _myCreator, _myDataBrowser, Sizeof(browser), browser )// Store our custom DataBrowser ID as a window property
End If
Window _mainWnd// Make the window visible
On Menu Fn doMenu
On Dialog Fn doDialog
Do
Handleevents
Until _nil
End Fn
// The start
Fn StartProgram
'~---
'~Applications Proc
/*
Entry point for the callback procedure
*/
#If Def _FBUseDebugger
Troff
#Endif
Goto "skip procs"
"GetSetItemDataProc"
Enterproc Fn GetSetItemDataProc( browser As ControlRef, itemID As DataBrowserItemID, prop As DataBrowserPropertyID, itemData As DataBrowserItemDataRef, changeValue As Boolean ) = OSStatus